[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+-----------+##############################################################
#+-| I_ROUND() |------------------------------+###############################
#| +-----------+ Rounds argument to integer & |###############################
#| returns integer as type LONG |###############################
#+--------------------------------------------+###############################
##############################################################################
##############################################################################
#+--| Summary |--------------+################################################
#| #INCLUDE math.hdr |################################################
#+---------------------------+################################################
##############################################################################
##############################################################################
#+--| Syntax |-----------------------------+##################################
#| FUNCTION LONG i_round PROTOTYPE |##################################
#| PARAMETERS CONST DBL argument |##################################
#+-----------------------------------------+##################################
##############################################################################
##############################################################################
#########+---| Description |----------------------------------------+#########
#########| The i_round() function rounds argument to an integer and |#########
#########| returns the integer as type LONG. This is the same as: |#########
#########| |#########
#########| i_trunc( argument+0.5 ) |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+---| Design |---------------------------------------------+#########
#########| The i_round() function exists to allow the development |#########
#########| of "Warning-less" code. The FORCE compiler issues a |#########
#########| WARNING whenever a loss of precision occurs (i.e., going |#########
#########| from a double-precision number to an integer). The |#########
#########| WARNING itself is harmless and exists to ALERT you to a |#########
#########| condition which COULD be an error. see error codes, |#########
#########| for more information. |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| |#########
#########| FUNCTION INT get_array_index |#########
#########| PARAMETERS CONST DBL big_val |#########
#########| |#########
#########| VARDEF |#########
#########| INT array_val |#########
#########| ENDDEF |#########
#########| |#########
#########| array_val = i_round(big_val / 10.4) |#########
#########| RETURN array_val |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| |#########
#########| ? i_round( 10.2 ) |#########
#########| ? i_round( 10.5 ) |#########
#########| ? i_round( 10.99 ) |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
i_trunc()
round()
trunc()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson